package com.skstudio.reportview;

import com.skstudio.report.ReportProcess;
import com.skstudio.report.SpyData;

public class ReporterProcess extends ReportViewController {

    ReportProcess mProc = null;

    @Override
    public void setSpyData(SpyData ref) {
        super.setSpyData(ref);
        mProc = ref.getReportProcess();
    }

    @Override
    public int getReportRows() {
        return 2;
    }

    @Override
    public int getReportColumns() {
        return mProc.getDataSize();
    }

    @Override
    public int getEntry(int row, int col) {
        if (row == 0 && mProc.mDataList.size() > col) {
            return (int) (mProc.mDataList.get(col).mPctKernel + mProc.mDataList.get(col).mPctUser);
        }
        if (row == 1 && mProc.mDataList.size() > col) {
            return (int) (mProc.mDataList.get(col).mPctKernel);
        }
        return 0;
    }

    @Override
    public String getEntryHint(int col) {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("Current usage(pid %d): ", mProc.mPid));
        sb.append(String.format("total %d%%, kernel %d%%", getEntry(0, col), getEntry(1, col)));
        return sb.toString();
    }
}
